package com.fagejiang.gateway.controller;

import com.fagejiang.gateway.config.CustomRouteConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * TODO
 *
 * @author 发哥讲Java
 * @version 1.0
 * @date 2021-05-17 17:53
 */
@RestController
@RequestMapping("/gateway")
public class GateWayController {

    @Autowired
    CustomRouteConfig customRouteConfig;

    @GetMapping("/list")
    public Object getList() {
        return customRouteConfig.getRouteDefinitions();
    }

    @GetMapping("/add")
    public Object add() {
        customRouteConfig.add();
        return "success add !";
//        return customRouteConfig.getRouteDefinitions();
    }

    @GetMapping("/delete/{id}")
    public Object add(@PathVariable("id") String id) {
        customRouteConfig.delete(id);
        return "success delete !";
//        return customRouteConfig.getRouteDefinitions();
    }
}
